<!DOCTYPE html>
<html>

<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <title>资料录入</title>
    <meta name="viewport" content="initial-scale=1, maximum-scale=1">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <link rel="stylesheet" href="/static/wx/lib/sui/sm.min.css">
    <link rel="stylesheet" href="/static/wx/lib/sui/sm-extend.min.css">
    <link rel="stylesheet" href="/static/wx/css/reset.css">
    <link rel="stylesheet" href="/static/wx/css/main.css">
    <link rel="stylesheet" href="/static/wx/css/public_main.css">
</head>

<body>
    <div class="page-group">
        <div class="page page-current" id="filerecord">

            <!-- 主内容 -->
            <div class="content">
                <div class="setp-card">
                    <div class="step-box">
                        <div class="step-item selected">
                            <div class="step-item-line">
                                <span></span>
                            </div>
                            <div class="step-item-text size-65">保单险种</div>
                        </div>
                        <div class="step-item selected">
                            <div class="step-item-line">
                                <span></span>
                            </div>
                            <div class="step-item-text size-65">货品信息</div>
                        </div>
                        <div class="step-item">
                            <div class="step-item-line">
                                <span></span>
                            </div>
                            <div class="step-item-text size-65">货品受损</div>
                        </div>
                        <div class="step-item">
                            <div class="step-item-line">
                                <span></span>
                            </div>
                            <div class="step-item-text size-65">货品现状</div>
                        </div>
                        <div class="step-item">
                            <div class="step-item-line">
                                <span></span>
                            </div>
                            <div class="step-item-text size-65">物权信息</div>
                        </div>
                        <div class="step-item">
                            <div class="step-item-line">
                                <span></span>
                            </div>
                            <div class="step-item-text size-65">递交授权</div>
                        </div>
                    </div>
                    <div class="size-65 text-c">
                        以下资料作为法律责任依据请如实填写，<span class="blue">查看模版>></span>
                    </div>
                </div>
                <input type="hidden" value="{$policy_num}" name ='policy_num'>
                <div class="bs-box">
                    <div class="bs-box-content">
                        <div class="bs-box-inner">
                            <div class="bs-box-content-item width-link size-m">
                                <div>货品类别</div>
                                <div>
                                    <input placeholder="请选择货品类别"  id="good_type" value="{if isset($info.goods_type_name)}{$info.goods_type_name}{/if}"/>
                                </div>
                            </div>
                            <div class="bs-box-content-item" >
                                <p class="size-m">货品名称</p>
                                <div>
                                    <input class="size-m" type="text" placeholder="请填写货品名称" name="goods_name" value="{if isset($info.goods_name)}{$info.goods_name}{/if}"/>
                                </div>
                            </div>
                            <div class="bs-box-content-item">
                                <p class="size-m">联系数量与规格</p>
                                <div>
                                    <input class="size-m" type="text" placeholder="请填写数量与规格" name="goods_num" value="{if isset($info.goods_num)}{$info.goods_num}{/if}"/>
                                </div>
                            </div>
                            <div class="bs-box-content-item size-m notshow-link">
                                <div>物品原值</div>
                                <div>
                                    <input placeholder="请填写"  name="good_price"  value="{if isset($info.good_price)}{$info.good_price| floor}{/if}"/>
                                </div>
                                <div>万元</div>
                            </div>
                            <div class="bs-box-content-item size-m notshow-link">
                                <div>评估价</div>
                                <div>
                                    <input placeholder="请填写" name="good_pg_price"  value="{if isset($info.good_pg_price)}{$info.good_pg_price |floor}{/if}"/>
                                </div>
                                <div>万元</div>
                            </div>
                            <div class="bs-box-content-item size-m">
                                <p style="color: red">注：评估价将作为起拍价使用</p>
                            </div>
                        </div>
                    </div>
                </div>
                <div class="btn-box" style="margin-top: 1rem;">
                    <div class="flex">
                        <div class="pre-step my-btn" style="width:47%;" @click="preStep" id="preStep">
                            <span style="background-color: #fff;color:#000;">上一步</span>
                        </div>
                        <div class="pre-step my-btn" style="width:47%" @click="nextStep" id="nextStep">
                            <span class="active">下一步</span>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
    </div>
    </div>
    <script type='text/javascript' src='/static/wx/lib/sui/zepto.min.js' charset='utf-8'></script>
    <script type='text/javascript' src='/static/wx/lib/sui/sm.min.js' charset='utf-8'></script>
    <script type='text/javascript' src='/static/wx/lib/sui/sm-extend.min.js' charset='utf-8'></script>
    <script>
        $(function () {
            var n = $('.step-box').children().length;
            $('.step-item').css('width', document.body.clientWidth / n + 'px')

            var str = [];
            var typeArr = new Object();
            getType();
            //获取商品类型
            function getType() {
                $.ajax({
                    type: 'POST',
                    url: "{:url('index/goodsType')}",
                    data: {},
                    dataType: 'json',
                    async: false,
                    success: function (Json) {
                        if (Json.code == 200) {
                            typeArr = Json.data.type_list;
                            for (var i = 0; i < typeArr.length; ++i) {
                                str.push(typeArr[i].gt_name)
                            }
                        }
                    }
                });
            }
            $("#good_type").picker({
                cols: [
                    {
                        textAlign: 'center',
                        values: str,
                        cssClass: 'picker-items-col-normal'
                    }
                ],
                onClose:function(data){
                    console.log('closeDtat',data)
                }
            });
            $(document).on('click', '#preStep', function () {
               var poliecy = $("input[ name='policy_num']").val();
                location.href="{:url('insurer/step1')}?policy_num="+poliecy;
            });
            $(document).on('click', '#nextStep', function () {
                var poliecy = $("input[ name='policy_num']").val();
                var goods_name = $("input[ name='goods_name']").val();
                var goods_num = $("input[ name='goods_num']").val();
                var good_price = $("input[ name='good_price']").val();
                var good_pg_price = $("input[ name='good_pg_price']").val();
                var goods_type = $("#good_type").val();
                if (goods_name.length == 0) {
                    $.alert('请填写货品名称');
                    return;
                }
                if (goods_num.length == 0) {
                    $.alert('请填写数量与规格');
                    return;
                }
                if (good_price.length == 0) {
                    $.alert('请填写物品原值');
                    return;
                }
                if (good_pg_price.length == 0) {
                    $.alert('请填写评估价');
                    return;
                }

                for (var i = 0; i < typeArr.length; ++i) {
                    if(goods_type ==typeArr[i].gt_name){
                        goods_type =typeArr[i].gt_id
                    }
                }
                $.ajax({
                    type: 'POST',
                    url: "{:url('insurer/addInsurer')}",
                    data: {
                        'policy_num':poliecy,
                        'goods_type': goods_type,
                        'goods_name': goods_name,
                        'goods_num': goods_num,
                        'good_price': good_price,
                        'good_pg_price': good_pg_price,
                        'now_status':2
                    },
                    dataType: 'json',
                    success: function (Json) {
                        console.log(Json);
                        if (Json.code == 200) {
                            location.href="{:url('insurer/step3')}?policy_num="+poliecy;
                        } else {
                            $.alert('保存失败');
                        }
                    }
                });


            });
            $(document).on('click', '.blue', function () {
                location.href="{:url('index/test2')}"
            })
        });

    </script>
</body>

</html>